<template>
  <CloudDialog
    v-model:visible="visible"
    :loading="loading"
    title="版本说明"
    :width="700"
    :mask-closable="false"
    :before-ok="handleSubmit"
    :footer="false"
    :before-open="handleOpen"
    :before-close="handleClose">
    <!-- <div class="imprint-detail"><div v-html="markdownContent"></div></div> -->
    <a-textarea
      v-model="text"
      disabled
      :auto-size="{ maxRows: 18, minRows: 18 }"></a-textarea>
  </CloudDialog>
</template>
<script lang="ts" setup>
import type { DomainItem } from '@/apis/model/resolve'
import { type FormInstance } from '@arco-design/web-vue'
// import { marked } from 'marked'
const emit = defineEmits(['reload'])
const text = ref<string>('')
// import { v4 as uuidV4 } from 'uuid'
interface IProp {
  record?: DomainItem
}
// 上传的文件
const uploadFile = ref<File>()

//const isUnClick = ref(true)
const loading = ref<boolean>(false)
const fileList = ref<any[]>([])

//清空表单
const resetField = () => {
  formRef.value?.resetFields()
  formState.value = {
    imprint: '',
    version: '',
    file_key: '',
    file: undefined,
    id: undefined
  }
  fileList.value = []
  uploadFile.value = undefined
}

const visible = defineModel<boolean>('visible', { required: true })
const props = withDefaults(defineProps<IProp>(), {})
//const emit = defineEmits(['reload'])
const formRef = ref<FormInstance>()
const formState = ref({
  imprint: '',
  version: '',
  file_key: '',
  file: undefined,
  id: undefined
})
// const markdownContent = ref('')
const handleOpen = async () => {
  text.value = props.record?.imprint || ''
  // markdownContent.value = marked(props.record?.imprint || '')
}
const handleSubmit = async () => {
  // const error = await formRef.value?.validate()
  // if (error) return false
  // const fn = props.record ? updateApiResolveDomainApi : addApiResolveDomainApi
  // const data = props.record
  //   ? { id: props.record.id!, ...formState.value }
  //   : formState.value
  // return fn(data).then(() => {
  //   Message.success(msg)
  //   emit('reload')
  // })
}

const handleClose = () => {
  resetField()
  emit('reload')
  visible.value = false
}
</script>

<style scoped lang="less">
:deep(.arco-textarea) {
  -webkit-text-fill-color: #393c40;
}
.imprint-detail {
  display: flex;
  padding: 8px 12px;
  align-items: flex-start;
  gap: 6px;
  align-self: stretch;
  border-radius: 4px;
  border: 1px solid var(---color-border-4, #dfe2e5);
  background: var(---color-fill-1, #f7f8fa);
  height: 500px;
  overflow-x: hidden;
  overflow-y: auto;
}
</style>
